package lk.icta.core.web.action;

import lk.icta.common.AppConstants;
import lk.icta.common.web.WebConstants;
import lk.icta.common.web.action.BaseAction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Locale;

public class HomeAction extends BaseAction {

    private static final Logger logger = LoggerFactory.getLogger(HomeAction.class);

    private String sessionLanguage;

    public String welcome() {
        logger.debug("Welcome");
        return SUCCESS;
    }

    public String changeLanguage() {
        logger.debug("change Language method");
          // Locale locale = new Locale(languageDataEntry, country);
        session.put(WebConstants.SESSION_USER_LANG, new Locale(sessionLanguage,
                AppConstants.COUNTRY));
       // language = locale.getLanguage();
       // logger.debug("setting language : {}", language);
        addActionMessage(getText("pref_language_changed_successfully.label"));
        return SUCCESS;
    }

    public String getSessionLanguage() {
        return sessionLanguage;
    }

    public void setSessionLanguage(String sessionLanguage) {
        this.sessionLanguage = sessionLanguage;
    }
}
